package com.neusoft.mapper;

import com.neusoft.po.User;
import com.neusoft.po.UserAvatar;
import com.neusoft.po.UserPsd;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
	
 @Select("select * from user where userId=#{userId} and password=#{password}")
 public User getUserByIdByPass(User user);
 
 @Select("select * from user where userId=#{userId}")
 public User getUserById(String userId);
 
 @Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},'',1)")
 public int saveUser(User user);
 
 @Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},#{userImg},1)")
 public int saveUser2(User user);

 @Update("UPDATE user u SET u.userImg =#{userImg} WHERE u.userId =#{userId}")
 public int changeUserAvatar(UserAvatar userAvatar);

 @Update("update user set password=#{newPassword} where userId=#{userId} and password=#{oldPassword}")
 public int changeUserPassword(UserPsd userPsd);
 
 @Update("UPDATE user SET userName=#{userName} WHERE userId=#{userId}")
 public int changeUserName(User user);
 
 @Select("select count(*) from user where userId=#{userId}")
 public int userIdExists(User user);

}